package com.staka.website.pages.user;

import java.util.Date;

import org.apache.tapestry5.alerts.AlertManager;
import org.apache.tapestry5.annotations.InjectComponent;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.corelib.components.Zone;
import org.apache.tapestry5.hibernate.annotations.CommitAfter;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.hibernate.Session;

import com.staka.website.forms.CommentForm;

public class Comment {
	@Property
	private CommentForm commentform;
	
	@Inject
	private Session session;
	
	@Inject
	private AlertManager alertManager;
	
	@InjectComponent
	private Zone zone;
	
	private Date date = new Date();
	
	@CommitAfter
	Object onSuccess(){
		session.save(commentform);
		alertManager.info(commentform.getName()+", you added your comment succesfully at: "+date.toString());
		return null;
	}
}
